<extend name="Index/index" />
<block name="center">
<div class="panel panel-blue">
    <div class="panel-heading">修改分类</div>
        <div class="panel-body pan">
                <form action="{:U('Admin/Mclass/update')}" class="form-horizontal" method="post">
                    <div class="form-actions top">
                        
                    </div>
                    <div class="form-body pal">
                        <div class="form-group">
                            <label for="inputAddress" class="col-md-3 control-label">分类名称 <span class="require">*</span>
                            </label>
                            <div class="col-md-9">
                                <div class="input-icon right" ><i class="fa fa-location-arrow"></i>
                                    <div style="float:left"><input type="text" class="form-control" name="cname" id="Mclass" style="width:300px" value="{$info[0]['cname']}"></div><div style="float:left"><span id="con" error="输入的类名已经存在" success="√" kong="类名不能为空" style="font-size:20px"></span></div>
                                    <input type="hidden" name="id" value="{$info[0]['id']}">
                                </div>
                            </div>
                        </div>
                        
                    </div>
                    <div class="form-actions">
                        <div class="col-md-offset-3 col-md-9">
                            <button type="submit" class="btn btn-primary">修改</button>&nbsp;
                            <button type="reset" class="btn btn-green">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
             <script type="text/javascript" src="__PUBLIC__/js/jquery-1.8.3.min.js"></script>
            <script type="text/javascript">
        $(function(){
            var statu = false;
            $('#Mclass').blur(function(){
                var res = $(this).val();
                // alert(res);
                if(res == ''){
                    // alert(2);
                    // alert(1);
                        var re = $('#con').attr('kong');
                        // console.log(re);
                        $('#con').html(re).css('color','red');
                        statu = false;
                        // die();
                }else{
                        // alert(res);
                        // $.post('{:U("Admin/Mclass/ajax")}',{'res':res},function(data){
                        //     // alert(data);
                        //     if(data != 0){
                        //         // alert(1);
                        //         var re = $('#con').attr('success');
                        //         // console.log(re);
                        //         $('#con').html(re).css('color','blue');
                        //         statu = true;
                        //     }else{
                        //         // alert(0);
                        //         var re = $('#con').attr('error');
                        //         $('#con').html(re).css('color','red');
                        //         statu = false;
                        //         // console.log(re);
                        //     }
                        // });
                        $.ajax({
                            url:'{:U("Admin/Mclass/ajax")}',
                            data:{'res':res},
                            type:'POST',
                            success: function(data){
                                if(data != 0){
                                    // alert(1);
                                    var re = $('#con').attr('success');
                                    // console.log(re);
                                    $('#con').html(re).css('color','blue');
                                    statu = true;
                                }else{
                                    // alert(0);
                                    var re = $('#con').attr('error');
                                    $('#con').html(re).css('color','red');
                                    statu = false;
                                    // console.log(re);
                                }
                            },
                            async: false//是否异步  x.open('GET','1.php', true);
                        });

                        
                    }

                
                
            })
            $('.form-horizontal').submit(function(){
                $('#Mclass').trigger('blur');
                if(statu == true) return true;

                return false;
            })
        })
        </script>
</block>